package com.app.logcat;

import android.app.Activity;
import android.os.Bundle;
import android.util.Log;

import androidx.annotation.Nullable;

import java.util.Timer;
import java.util.TimerTask;

/**
 * Created by lzy on 2021/1/20.
 */
public class SecondActivity extends Activity {
    private Timer timer;
    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        setContentView(R.layout.activity_second);

        timer = new Timer();
        timer.schedule(new TimerTask() {
            @Override
            public void run() {
                Log.w("fff", "2222222222222222222");
            }
        }, 0 ,1000);
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        if (null != timer) {
            timer.cancel();
            timer = null;
        }
    }
}
